home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / EXT / A-E / ByeBye.cpt / Byebye.Asm next >
Assembly Source File  |  1988-03-03  |  4KB  |  130 lines

  1. ;
  2. ; Bye-bye (shutdown) sound effect INIT
  3. ;
  4. ; © 1988 By Jim Nitchals, Compuserve ID 71001,2232.
  5. ;
  6. ; Comments or mail can also be left via the ECHOMAC BBS network.
  7. ;
  8. ; Call (415) 855-9548 by modem if you don't know a local number.
  9. ;
  10. ; This program is being distributed as shareware.  Send whatever
  11. ; you think this program is worth to your favorite local BBS operator.
  12. ; He/she could probably use the money.
  13. ;
  14. ; This program may NOT be sold, or included as part of any for-sale
  15. ; package (including but not limited to bundled public domain packages.)
  16. ;
  17. ;
  18. ; Forgive some of the nonMDS-compatible syntax.  I use my own assembler,
  19. ; not MDS or MPW.  You'll have to rewrite or remove parts of this mess
  20. ; if you want to use this actual code.  Sorry.
  21. ;
  22. ; The source code is provided for informational purposes only.
  23. ; Any modifications are the sole responsibility of the programmer
  24. ; changing the code.  Any shutdown sound utility based on this code
  25. ; MUST include my name in the credits.
  26. ;
  27. ; This program is provided on an as-is basis, without any guarantee
  28. ; as to function or reliability.
  29. ;
  30. ;
  31. ; I'd like to apologize for the sound data sitting around in memory
  32. ; all the time, wasting valuable system heap.  But it's only 14K.
  33. ;
  34.     68000        ; directives for my assembler
  35.     ORG 0        ; set relative origin to 0
  36.     EMUL8        ; yet another stupid directive
  37.     Stringform 3    ; equivalent to MDS "String_Format 3"
  38. ;
  39. ; System equates (equivalent to the MDS equates, more-or-less)
  40.     include    Batcave:Xasm:JMacro.Asm
  41.     include    Batcave:Xasm:JSysequ
  42.     include    Batcave:Xasm:Traps
  43.  
  44. ; ***********************************************************************
  45. ; This is the code which is executed during boot-up.  It allocates
  46. ; system heap memory sufficient for the shutdown procedure, and
  47. ; copies itself there.
  48. Start:
  49. ; don't install self if the mouse button is being held down.
  50.     tst.b    MBstate
  51.     beq    @abort
  52.     movem.l    d0-d7/a0-a6,-(sp)
  53. ; allocate memory:
  54.     move.l    #InitEND,d0
  55.     _NewPtrSys        ; _NewPtr ,Sys
  56.     tst.w    d0
  57.     bmi.s    @error
  58.     move.l    a0,a2        ; the pointer to the destination
  59.     lea    Start(pc),a1    ; pointer to the start
  60.     move    #InitEND-1,d0
  61. @copy    move.b    (a1)+,(a0)+    ; klutzy block move
  62.     dbra    d0,@copy
  63.     pea    MyShutProc(a2)    ; 
  64.     move    #1,-(SP)        ; flag: before power off only
  65.     _ShutdwnInstall        ; MPW: Move #3,-(sp); _Shutdown 
  66. @error:
  67.     movem.l    (sp)+,d0-d7/a0-a6
  68. @abort    rts
  69. ;
  70. ; ***********************************************************************
  71. ; My shutdown procedure.  Gets called only when a "Shut down" command
  72. ; is executed, and power is about to go off.
  73. MyShutProc:
  74. ; this shut-down procedure uses the OLD Sound driver.  This should
  75. ; in theory make it compatible with more Macintosh models.
  76.     movem.l    d0-d7/a0-a6,-(sp)
  77.     lea    ioRec(pc),a0
  78.     move    #-4,ioRefnum(a0)
  79.     lea    Synthrec(pc),a1
  80.     move.l    a1,ioBuffer(a0)
  81.     move.l    #SynthSize,ioReqCount(a0)
  82.     _Write
  83. ; delay for 1/3 second.  I could be polling the ioResult of the record
  84. ; but am too lazy.  This delay may need adjusting based on 
  85.     move.l    Ticks,d0
  86.     add.l    #20,d0
  87. @wait    cmp.l    Ticks,d0
  88.     bcc.s    @wait
  89.     movem.l    (sp)+,d0-d7/a0-a6
  90.     rts
  91.  
  92. ioRec    dcb.b    ioQElSize,0
  93.     dc.b    'Byebye init resource © 1988 by James Nitchals.'
  94.     dc.w    0    ; word-align the object code
  95. ;
  96. ; The sound synthesizer record:
  97. Synthrec:
  98.     dc.w    0    ; mode=ffMode
  99.     dc.w    1,$6000    ; skip-sample amount (integer, fraction)
  100. ;
  101. ; Waveform data is loaded as in-line code from a Soundcap data file.
  102. ; Be SURE your waveform data file isn't over 32,000 bytes
  103. ; in order to avoid the 32K resource size limit.
  104. ; the BLOAD command in my assembler loads raw data from the data fork of
  105. ; a file.
  106. WaveStart:
  107.     BLOAD    Batcave:Nifty:ByeBye
  108. SynthSize    equ    *-WaveStart
  109.  
  110. InitEND    equ    *-Start
  111. ;
  112. ; a resource called "sysz" must be created: a long-word telling
  113. ; the INIT package how much system heap we want.  If you don't include
  114. ; this resource, sounds larger than 13K or so can't be loaded.
  115. syszData:
  116.     dc.l    syszEND-Start
  117. syszEND    equ    *
  118. ;
  119. ;
  120. ; ***********************************************************************
  121. ; Save the INIT and sysz resources.
  122. ; You'd probably set up an MDS Link file
  123. ; to convert the above code into the correct resource types.
  124. ;        TYPE   ID  OFFSET    LENGTH        OUTPUT FILE
  125. ;
  126.     rsave    'INIT', 1,Start,    InitEND-Start,    Batcave:ByebyeINIT
  127.     rsave    'sysz', 0,syszData,    syszEND-syszData,    Batcave:ByebyeINIT
  128.  
  129.     end
  130.